<?php

require_once '../config.php';

require_once '../includes/functions.php';

if (!isLoggedIn()) {

    redirect('../login.php');

}

if ($_SERVER['REQUEST_METHOD'] === 'POST') {

    $apps = getApps();

    foreach ($apps as $key => $app) {

        if ($app['id'] === $_POST['id']) {

            unset($apps[$key]);

            break;

        }

    }

    

    saveApps($apps);

    redirect('../admin.php');

} else {

    redirect('../admin.php');

}

?>